<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>anchor</title>
    <script type="text/javascript">
        window.onload=function () {
            document.getElementById("btn1").onclick=function () {
                document.getElementById("myanchor").innerHTML="淘宝";
                document.getElementById("myanchor").href="https://www.taobao.com/";
            }
        }
    </script>
</head>
<body>
<a id="myanchor" href="http://www.baidu.com/">百度</a><br>
<input id="btn1" type="button" value="改变链接">
</body>
</html>